package com.lsw.decoding;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.lsw.R;
import com.lsw.util.StringUtil;

import static com.lsw.util.StringUtil.web;

/**
 * Created by Administrator on 2018/4/18 0018.
 */

public class WebViewActivity extends Activity {
    WebView webview;
    String url = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_webview);
        webview = findViewById(R.id.webview);
        webview.getSettings().setJavaScriptEnabled(true);
//        webview.setWebViewClient(new WebViewClient() {
//            @Override
//            public boolean shouldOverrideUrlLoading(WebView view, String url) {
//                view.loadUrl(url);
//                return true;
//            }
//        });

        url = getIntent().getStringExtra("result");
        if (!StringUtil.isNullOrEmpty(url)) {
            if (url.startsWith("http")) {
                webview.loadUrl(url);
            } else {
                webview.loadDataWithBaseURL(null, web + url, "text/html", "utf-8", null);
            }
        }

    }
}
